package cn.funeralobjects.upms.converter;

import cn.funeralobjects.upms.enums.Protocol;

import javax.persistence.AttributeConverter;

/**
 * protocol转换器
 *
 * @author FuneralObjects
 * Create date: 2020/4/26 11:31 AM
 */
public class ProtocolConverter implements AttributeConverter<Protocol, String> {
    @Override
    public String convertToDatabaseColumn(Protocol attribute) {
        return attribute == null ? null : attribute.name();
    }

    @Override
    public Protocol convertToEntityAttribute(String dbData) {
        return dbData == null ? null : Protocol.valueOf(dbData);
    }
}
